<?php

/**
 * @author ducnhat
 * @copyright 2014
 */

/*========== CUSTOMIZE ===========*/

function dn_customize_register($wp_customize){
    $categoriesArr = get_categories();
    $default = current($categoriesArr);
    
    $wp_customize->add_section('home_testimonial', array('title' => 'Testimonial', 'priority' => 31));
    $wp_customize->add_setting('home_setting_testimonial', array('default' => $default->cat_ID));
    $wp_customize->add_setting('home_setting_testimonial_title', array('default' => "TESTIMONIAL"));
    
    $wp_customize->add_section('home_slider', array('title' => 'Slider', 'priority' => 29));
    $wp_customize->add_setting('home_setting_slider', array('default' => $default->cat_ID));
    
    $wp_customize->add_section('home_portfolio', array('title' => 'Portfolio', 'priority' => 30));
    $wp_customize->add_setting('home_setting_portfolio', array('default' => $default->cat_ID));
    $wp_customize->add_setting('home_setting_portfolio_title', array('default' => "Portfolio"));
    
    $wp_customize->add_section('about', array('title' => 'About Us', 'priority' => 32));
    $wp_customize->add_setting('about_setting_category', array('default' => $default->cat_ID));
    $wp_customize->add_setting('about_setting_title', array('default' => "About Us"));
    
    $categories = array();
    
    foreach($categoriesArr as $c){
        $categories[$c->cat_ID] = $c->name;
    }
    
    $controlTitle = new WP_Customize_Control(
        $wp_customize,
        'home_setting_testimonial_title',
        array(
            'label'          => __( 'Title', 'lskt' ),
            'section'        => 'home_testimonial',
            'settings'       => 'home_setting_testimonial_title',
            'type'           => 'text'
        )
    );
    
    $controlCategories = new WP_Customize_Control(
        $wp_customize,
        'home_setting_testimonial',
        array(
            'label'          => __( 'Select categories', 'lskt' ),
            'section'        => 'home_testimonial',
            'settings'       => 'home_setting_testimonial',
            'type'           => 'select',
            'choices'        => $categories
        )
    );
    
    $controlSliderCategories = new WP_Customize_Control(
        $wp_customize,
        'home_setting_slider',
        array(
            'label'          => __( 'Select categories', 'lskt' ),
            'section'        => 'home_slider',
            'settings'       => 'home_setting_slider',
            'type'           => 'select',
            'choices'        => $categories
        )
    );
    
    $controlPortfolioTitle = new WP_Customize_Control(
        $wp_customize,
        'home_setting_portfolio_title',
        array(
            'label'          => __( 'Title', 'lskt' ),
            'section'        => 'home_portfolio',
            'settings'       => 'home_setting_portfolio_title',
            'type'           => 'text'
        )
    );
    
    $controlPortfolioCategories = new WP_Customize_Control(
        $wp_customize,
        'home_setting_portfolio',
        array(
            'label'          => __( 'Select categories', 'lskt' ),
            'section'        => 'home_portfolio',
            'settings'       => 'home_setting_portfolio',
            'type'           => 'select',
            'choices'        => $categories
        )
    );
    
    $controlAboutTitle = new WP_Customize_Control(
        $wp_customize,
        'about_setting_title',
        array(
            'label'          => __( 'Title', 'lskt' ),
            'section'        => 'about',
            'settings'       => 'about_setting_title',
            'type'           => 'text'
        )
    );
    
    $controlAboutCategories = new WP_Customize_Control(
        $wp_customize,
        'about_setting_category',
        array(
            'label'          => __( 'Select categories', 'lskt' ),
            'section'        => 'about',
            'settings'       => 'about_setting_category',
            'type'           => 'select',
            'choices'        => $categories
        )
    );
    
    $wp_customize->add_control($controlTitle);
    $wp_customize->add_control($controlCategories);
    $wp_customize->add_control($controlSliderCategories);
    $wp_customize->add_control($controlPortfolioTitle);
    $wp_customize->add_control($controlPortfolioCategories);
    $wp_customize->add_control($controlAboutTitle);
    $wp_customize->add_control($controlAboutCategories);
}
add_action('customize_register', 'dn_customize_register');

/*========== END CUSTOMIZE ===========*/

?>